package com.six.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.six.pojo.Customer;
import com.six.pojo.CustomerContacts;
import com.six.pojo.vo.CustomerVo;
import com.six.result.Result;
import com.six.result.ResultUtils;
import com.six.service.CustomerContactService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * @author luolu
 * @create 2022/3/7 17:32
 */
@Controller
@ResponseBody
@RequestMapping("/customerContact")
@Api(tags = "客户联系人接口")
public class CustomerContactController {
    @Autowired
    private CustomerContactService customerContactService;

    /**
     * 添加联系人
     * @param customerContacts
     * @return
     */
    @ApiOperation(value = "新增联系人数据" ,notes = "新增联系人数据")
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 200, message = "请求成功！")
    })
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    //RequestBody 规定为json格式的数据
    public Result add(@RequestBody @ApiParam(name = "CustomerContacts", value = "新增的联系人字段") CustomerContacts customerContacts){
        customerContactService.save(customerContacts);
        return ResultUtils.buildSuccess();
    }


    /**
     * 根据id删除联系人
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id删除联系人" ,notes = "根据id删除联系人")
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 200, message = "请求成功！")
    })
    @RequestMapping(value = "/deleteById",method = RequestMethod.GET)
    public Result delete(@RequestParam @ApiParam(name = "id", value = "联系人的id")Long id){
        customerContactService.removeById(id);
        return ResultUtils.buildSuccess();
    }



}
